// 国内手机号验证
export const isPhone = (str: string): boolean => {
    var reg = /^(1[3-9][0-9])[0-9]{8}$/;
    return reg.test(str)
}
// 全球手机号验证（区分区号）
export const isAreaPhone = (str: string, areaCode: string) => {
    return areaCode === "86" ? isPhone(str) : /[\d]{5,}$/.test(str);
};
// 验证码
export const isVerifyCode = (str: string) => {
    return /[\d]{6}$/.test(str);
}
// 邮箱验证
export const isEmail = (str: string): boolean => {
    var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    // var reg = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    return reg.test(str)
}
// 数字验证
export const isNumber = (value: string): boolean => {
    var patrn = /^[0-9]*$/;
    return !(patrn.exec(value) == null || value == "")
}
// 验证输入金额
export const isMoney = (value: string): boolean => {
    var patrn = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
    return !(patrn.exec(value) == null || value == "")
}
// 身份证号码验证
export const isCardNo = (card: string): boolean => {
    // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X  
    var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    return reg.test(card)
}
// 全为空格时的验证
export const isAllSpace = (value): boolean => {
    var reg = /^\s+$/g;
    return reg.test(value)
}
// 有中文的验证
export const isChinese = (value): boolean => {
    var reg = /[\u4e00-\u9fa5]/g;
    return reg.test(value)
}
// 最大长度验证
export const maxLength = (value, maxlength): boolean => {
    return !(value.replace(/[^\x00-\xff]/g, "aa").length > maxlength)
}
